import {request} from "../../request/index.js"


const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    url:'',
    historyUserList: '',
    reason: '',
    badHistoryList: '',
    tabs: [
      {
        id: 0,
        name: '正常停电',
        isActive: true
      },
      {
        id: 1,
        name: '故障停电',
        isActive: false
      }
    ]
  },
  onLoad: function (options) {
    request({
      url: '/client/query/blackout/' + app.userId,
      method: 'POST',
      data: {
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      }
    })
    .then(res => {
      console.log(res)
      this.setData({
        historyUserList: res.data
      })
    })

    request({
      url: '/client/query/malfunction/' + app.userId,
      method: 'POST',
      data: {
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      }
    })
    .then(res => {
      console.log(res)
      this.setData({
        badHistoryList: res.data
      })
    })
  },
  onShow() {

  },
  handleItemTags(e) {
    const {index} = e.detail
    let {tabs} = this.data
    tabs.forEach((v, i) => i===index? v.isActive=true: v.isActive=false)
    this.setData({
      tabs
    })
  }
})